package com.example.gaoyang.enums;

/**
 * 开门状态枚举
 */

public enum VehicleOpenStateEnum {
    AUTO("自动", "0"),
    MANUAL("手动", "1"),
    REMOTE("遥控", "2"),
    PROHIBITED("禁止通行", "3");

    private final String name;
    private final String code;

    VehicleOpenStateEnum(String name, String code) {
        this.name = name;
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public String getCode() {
        return code;
    }

    /**
     * 根据code获取名称
     * @param code
     * @return
     */
    public static String getNameByCode(String code) {
        for (VehicleOpenStateEnum vehicleOpenStateEnum : VehicleOpenStateEnum.values()) {
            if (vehicleOpenStateEnum.getCode().equals(code)) {
                return vehicleOpenStateEnum.getName();
            }
        }
        return null;
    }
}
